<template>
    <div class="">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-message"></i> 置换交易列表</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
                <el-form :inline="true"  class="demo-form-inline">
                    <el-form-item label="置换订单号:">
                        <el-input v-model="orderCode" placeholder="请输入置换订单号" clearable style="width:300px;"></el-input>
                    </el-form-item>
                    <el-form-item label="双方账号昵称:">
                        <el-input v-model="nickName" placeholder="请输入双方账号昵称" clearable style="width:300px;"></el-input>
                    </el-form-item>
                    <el-form-item label="双方手机号:">
                        <el-input v-model="mobile" placeholder="请输入双方手机号" clearable style="width:300px;"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSelect"> &nbsp;&nbsp;查询&nbsp;&nbsp;  </el-button>
                    </el-form-item>
                </el-form>
                 <el-tabs v-model="activeName" @tab-click="handleClick">
				    <el-tab-pane label="所有订单" name="0"></el-tab-pane>
				    <el-tab-pane label="待确认同意置换" name="1"></el-tab-pane>
				    <el-tab-pane label="双方支付保证金" name="2"></el-tab-pane>
				    <el-tab-pane label="双方发货" name="3"></el-tab-pane>
				    <el-tab-pane label="平台已收货" name="4"></el-tab-pane>
				    <el-tab-pane label="平台已发货" name="5"></el-tab-pane>
				    <el-tab-pane label="交易成功" name="6"></el-tab-pane>
				    <el-tab-pane label="交易关闭" name="7"></el-tab-pane>
				    <el-tab-pane label="申请关闭" name="8"></el-tab-pane>
				  </el-tabs>
                <el-table :data="tableData" style="width: 100%"   ref="multipleTable">
                	<el-table-column type="expand">
				      <template slot-scope="props">
				        <el-form label-position="left" inline class="demo-table-expand">
				        	<!--置换方-->
				        	<el-form-item label="发起置换方用户ID">
					            <span>{{ props.row.buyer_id }}</span>
					        </el-form-item>
					        <el-form-item label="被置换方用户ID">
					            <span>{{ props.row.seller_id }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方用户昵称">
					            <span>{{ props.row.buyer_nickname }}</span>
					        </el-form-item>
					         <el-form-item label="被置换方用户昵称">
					            <span>{{ props.row.seller_nickname }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方联系方式">
					            <span>{{ props.row.buyer_mobile }}</span>
					        </el-form-item>
					         <el-form-item label="被置换方联系方式">
					            <span>{{ props.row.seller_mobile }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方收件人">
					            <span>{{ props.row.buyerAddress.name }}</span>
					        </el-form-item>
					        <el-form-item label="被置换方收件人">
					            <span>{{ props.row.sellerAddress.name }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方收件地址">
					            <span>{{ props.row.buyerAddress.province + props.row.buyerAddress.city + props.row.buyerAddress.district + props.row.buyerAddress.address }}</span>
					        </el-form-item>
					        <el-form-item label="被置换方收件地址">
					            <span>{{ props.row.sellerAddress.province + props.row.sellerAddress.city + props.row.sellerAddress.district + props.row.sellerAddress.address }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方收件人电话">
					            <span>{{ props.row.buyerAddress.mobile }}</span>
					        </el-form-item>
					        <el-form-item label="被置换方收件人电话">
					            <span>{{ props.row.sellerAddress.mobile }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方邮编">
					            <span>{{ props.row.buyerAddress.zip_code }}</span>
					        </el-form-item>
					        <el-form-item label="被置换方邮编">
					            <span>{{ props.row.sellerAddress.zip_code }}</span>
					        </el-form-item>
					        <el-form-item label="发起置换方藏品信息">
					            <div class="goodslist" v-for="item in props.row.buyerGoodsList">
					        		<img style="display: inline-block;width: 100px;height: 100px;" :src="item.head_img"/>
						            <span>商品ID：{{item.id}} &nbsp;&nbsp;&nbsp;&nbsp; 数量：{{item.goods_num}} &nbsp;&nbsp;&nbsp;&nbsp;单价：￥{{item.goods_price}} &nbsp;&nbsp;&nbsp;&nbsp;总价：￥{{item.total_price}}</span>
				        		</div>
					        </el-form-item>
					        <el-form-item label="被置换方藏品信息">
					            <div class="goodslist">
					        		<img style="display: inline-block;width: 100px;height: 100px;" :src="props.row.sellerGoods.head_img"/>
						            <span>商品ID：{{props.row.sellerGoods.id}} &nbsp;&nbsp;&nbsp;&nbsp; 数量：{{props.row.sellerGoods.goods_num}} &nbsp;&nbsp;&nbsp;&nbsp;单价：￥{{props.row.sellerGoods.goods_price}} &nbsp;&nbsp;&nbsp;&nbsp;总价：￥{{props.row.sellerGoods.total_price}}</span>
				        		</div>
					        </el-form-item>
					        <el-form-item label="发起置换方保证金">
					            <span v-if="props.row.buyer_bond">{{ props.row.buyer_bond }}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="被置换方保证金">
					            <span v-if="props.row.seller_bond">{{ props.row.seller_bond }}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="发起置换方保证金支付方式">
					            <span v-if="props.row.buyer_bond_pay">{{ props.row.buyer_bond_pay | paytype}}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="被置换方保证金支付方式">
					            <span v-if="props.row.seller_bond_pay">{{ props.row.seller_bond_pay | paytype}}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="发起置换方保证金支付订单号">
					            <span v-if="props.row.buyer_bond_code">{{ props.row.buyer_bond_code }}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="被置换方保证金支付订单号">
					            <span v-if="props.row.seller_bond_code">{{ props.row.seller_bond_code }}</span>
					            <span v-else>未支付</span>
					        </el-form-item>
					        <el-form-item label="发起置换方发货快递公司">
					        	<span v-if="props.row.buyer_express_com">{{ props.row.buyer_express_com }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="被置换方发货快递公司">
					        	<span v-if="props.row.seller_express_com">{{ props.row.seller_express_com }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="发起置换方发货快递单号">
					        	<span v-if="props.row.buyer_express_code">{{ props.row.buyer_express_code }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="被置换方发货快递单号">
					        	<span v-if="props.row.seller_express_code">{{ props.row.seller_express_code }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="平台发货给发起置换方快递公司">
					        	<span v-if="props.row.platform_tobuyer_com">{{ props.row.platform_tobuyer_com }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="平台发货给被置换方快递公司">
					        	<span v-if="props.row.platform_toseller_com">{{ props.row.platform_toseller_com }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="平台发货给发起置换方快递单号">
					        	<span v-if="props.row.platform_tobuyer_com">{{ props.row.platform_tobuyer_code }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
					        <el-form-item label="平台发货给被置换方快递单号">
					        	<span v-if="props.row.platform_toseller_com">{{ props.row.platform_toseller_code }}</span>
					            <span v-else>未发货</span>
					        </el-form-item>
				        </el-form>
				      </template>
				    </el-table-column>
                    <el-table-column prop="id" label="置换订单ID" width="100" align="center">
                    </el-table-column>
                    <el-table-column prop="exchange_code" label="置换订单号" width="300" align="center">
                    </el-table-column>
                    <el-table-column prop="buyer_state" label="发起置换方状态" width="200" align="center" :formatter="buyStatu">
                    </el-table-column>
                    <el-table-column prop="buyer_address" label="被置换方状态" width="200" align="center" :formatter="SelStatu">
                    </el-table-column>
                    <el-table-column prop="submit_time" label="置换申请发起时间" width="200" align="center">
                    </el-table-column>
                    <el-table-column label="操作" align="center" >
                        <template slot-scope="scope" >
                            <el-button class="look" size="small" type="text" @click="handleDelete(scope.row,scope.$index)" v-if="scope.row.seller_state == 0 && activeName == 1 ">确认卖家是否同意置换</el-button>
                            <el-button class="look" size="small" type="text" @click="buyTakeVisibleFun(scope.row,scope.$index)" v-if="scope.row.buyer_state == 2 && activeName == 3  ">平台收到发起置换方藏品</el-button>
                            <el-button class="edit" size="small" type="text" @click="excTakeVisibleFun(scope.row,scope.$index)" v-if="scope.row.seller_state == 4 && activeName == 3 ">平台收到被置换方藏品</el-button>
                            <el-button class="look" size="small" type="text" @click="buySendVisibleFun(scope.row,scope.$index)" v-if="scope.row.buyer_state == 3 && scope.row.seller_state >= 5 && activeName == 4">置换方的藏品发给被置换方</el-button>
                            <el-button class="edit" size="small" type="text" @click="excSendVisibleFun(scope.row,scope.$index)" v-if="scope.row.seller_state == 5 && scope.row.buyer_state >= 3 && activeName == 4">被置换方的藏品发给置换方</el-button>
                            <el-button class="look" size="small" type="text" @click="buyReturnVisibleFun(scope.row,scope.$index)" v-if="scope.row.buyer_state == 5 && activeName == 6">处理发起置换方保证金</el-button>
                            <el-button class="look" size="small" type="text" @click="buyReturnVisibleFun(scope.row,scope.$index)" v-if="(scope.row.buyer_state == 1 || scope.row.buyer_state == 2 || scope.row.buyer_state == 3 || scope.row.buyer_state == 4 || scope.row.buyer_state == 8) && activeName == 8">处理发起置换方保证金</el-button>
                            <el-button class="edit" size="small" type="text" @click="excReturnVisibleFun(scope.row,scope.$index)" v-if="scope.row.seller_state == 7 && activeName == 6">处理被置换方保证金</el-button>
                            <el-button class="edit" size="small" type="text" @click="excReturnVisibleFun(scope.row,scope.$index)" v-if="(scope.row.seller_state == 3 || scope.row.seller_state == 4 || scope.row.seller_state == 5 || scope.row.seller_state == 6 || scope.row.seller_state == 10) && activeName == 8">处理被置换方保证金</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="pagination" v-show="totalPages>1">
                    <el-pagination v-if="paginationShow" @current-change="handleCurrentChange" layout="prev, pager, next" :page-size="pageSize" :total="totalElements" background>
                    </el-pagination>
                </div>
                
        </div>
        <!-- 确认提示框 -->
        <el-dialog title="提示" :visible.sync="delVisible" width="500px" center>
            <div class="del-dialog-cnt">确认卖家是否同意置换？</div>
            <div style="margin-top:10px;">
               <el-input v-model="refuseReason" placeholder="请输入拒绝原因（同意置换无须原因）"></el-input> 
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="deleteRow2">不同意</el-button>
                <el-button type="primary" @click="deleteRow">同意</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 -->
        <!-- 确认提示框 --平台收到发起置换方藏品-->
        <el-dialog title="提示" :visible.sync="buyTakeVisible" width="300px" center>
            <div class="del-dialog-cnt">平台是否收到发起置换方藏品？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="buyTakeVisible = false">取消</el-button>
                <el-button type="primary" @click="buyTakeVisibleFunOk">确认</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --平台收到发起置换方藏品-->
        <!-- 确认提示框 --平台收到被置换方藏品-->
        <el-dialog title="提示" :visible.sync="excTakeVisible" width="300px" center>
            <div class="del-dialog-cnt">平台是否收到被置换方藏品？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="excTakeVisible = false">取消</el-button>
                <el-button type="primary" @click="excTakeVisibleFunOk">确认</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --平台收到被置换方藏品-->
        <!-- 确认提示框 --保证金处理-置换方-->
        <el-dialog title="提示" :visible.sync="buyMarVisible" width="300px" center>
            <div class="del-dialog-cnt">发起置换方保证金处理？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="buyReturnVisibleFunNo">没收</el-button>
                <el-button type="primary" @click="buyReturnVisibleFunOk">退回</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --保证金处理-置换方-->
        <!-- 确认提示框 --保证金处理-被置换方-->
        <el-dialog title="提示" :visible.sync="excMarVisible" width="300px" center>
            <div class="del-dialog-cnt">被置换方保证金处理？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="excReturnVisibleFunNo">没收</el-button>
                <el-button type="primary" @click="excReturnVisibleFunOk">退回</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --保证金处理-被置换方-->
        <!-- 确认提示框 --发货-置换方的藏品发给被置换方-->
        <el-dialog title="置换方的藏品发给被置换方" :visible.sync="buySendVisible" width="300px" center>
            <div class="del-dialog-cnt">请选择快递公司</div>
            <el-select v-model="cityListChooseBuyKey" @change="cityListChooseBuyFun" placeholder="请选择快递公司">
			    <el-option
			      v-for="item in cityList"
			      :key="item.no"
			      :label="item.com"
			      :value="item.no">
			    </el-option>
			</el-select>
			<div style="height: 30px;"></div>
			<div class="del-dialog-cnt">请输入快递单号</div>
			<el-input v-model="expNumberBuy" placeholder="请输入快递单号"></el-input>
            <span slot="footer" class="dialog-footer">
                <el-button @click="buySendVisible = false">取消</el-button>
                <el-button type="primary" @click="buySendVisibleFunOk">发货</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --发货-置换方的藏品发给被置换方-->
        <!-- 确认提示框 --发货-被置换方的藏品发给置换方-->
        <el-dialog title="被置换方的藏品发给置换方" :visible.sync="excSendVisible" width="300px" center>
            <div class="del-dialog-cnt">请选择快递公司</div>
            <el-select v-model="cityListChooseSelKey" @change="cityListChooseSelFun" placeholder="请选择快递公司">
			    <el-option
			      v-for="item in cityList"
			      :key="item.no"
			      :label="item.com"
			      :value="item.no">
			    </el-option>
			</el-select>
			<div style="height: 30px;"></div>
			<div class="del-dialog-cnt">请输入快递单号</div>
			<el-input v-model="expNumberSel" placeholder="请输入快递单号"></el-input>
            <span slot="footer" class="dialog-footer">
                <el-button @click="excSendVisible = false">取消</el-button>
                <el-button type="primary" @click="selSendVisibleFunOk">发货</el-button>
            </span>
        </el-dialog>
        <!--确认提示框 --发货-被置换方的藏品发给置换方-->
    </div>
</template>
<script>
import {excListGet,excConfirm,receiveBuyerExc,receiveSellerExc,expressBuyerExc,expressSellerExc,refundBondBuyerExc,refundBondSellerExc,getExpressList} from '@/api/branch/exchange'
export default {
    name:"buyList",
    data() {
        return {
            pageIndex:1,//当前页码
            pageSize:10,//每页10条
            paginationShow:true,//分页器重新渲染
            cityData:[],//所有分站城市数据
            totalElements:1,//默认的总条数
            totalPages:1,//默认的总页数
            tableData:[],//表格数据
            delIndex:0, //当前选中的下标
            delId:0,  //当前要删除的Id
            orderCode:'', //购买订单号
            nickName:'', //双方账号昵称
            mobile:'', //双方手机号
            activeName:"0",//订单状态类型：0不限、1待确认同意置换、2双方支付保证金、3双方发货、4平台已收货、5平台已发货、6交易成功、7交易关闭
            delVisible:false, //确认弹框状态
            delId:0,  //当前要删除的Id
            buyTakeVisible:false, //收货-置换方
            buyTakeId:0,//收货-置换方-ID
            excTakeVisible:false, //收货-被置换方
            excTakeId:0,//收货-被置换方-ID
            buySendVisible:false, //发货-置换方
            buySendId:0,//发货-置换方-ID
            excSendVisible:false, //发货-被置换方
            excSendId:0,//发货-被置换方-ID
            buyMarVisible:false, //保证金-置换方
            buyMarId:0,//保证金-置换方-ID
            excMarVisible:false, //保证金-被置换方
            excMarId:0,//保证金-被置换方-ID
            cityList: [],//快递公司
	        cityListChooseBuy: '',//快递选择-置换方
	        cityListChooseBuyKey: '',//快递选择-置换方
	        expNumberBuy: '',//快递单号-置换方
	        cityListChooseSel: '',//快递选择-被置换方
	        cityListChooseSelKey: '',//快递选择-被置换方
            expNumberSel: '',//快递单号-被置换方
            refuseReason:'',//拒绝置换原因，同意可为空
        }
    },
    //实例创建
    created(){
    	//获取列表数据
		this.getDate();
		this.getExpList();
    },
    //计算属性
    computed:{

    },
    //数据过滤
    filters: {
    	//支付方式
	     paytype: function (val) {
	        let type;
	        if(val == 1){
	        	type = "支付宝"
	        }else if(val == 2){
	        	type = "微信"
	        }else if(val == 3){
	        	type = "余额"
	        }
	        return type;
	    },
	},
    //方法
    methods: {
    	//选中快递-置换方的藏品发给被置换方
    	cityListChooseSelFun(value){
	          let obj = {};
	          obj = this.cityList.find((item)=>{
	              return item.no === value;
	          });
	          this.cityListChooseSel = obj.com;
    	},
    	//发货-置换方的藏品发给被置换方
        excSendVisibleFun(row,index){
           if(row.id && row.id>0){
                this.excSendId = row.id; //确认ID
                this.excSendVisible = true; //显示兑换弹出框
            }
        },
        // 发货-置换方的藏品发给被置换方
        selSendVisibleFunOk(){
            let that = this;
            if(that.cityListChooseSel == ''){
            	this.$notify.error({
                    title: '异常',
                    offset: 100,
                    message: "请选择快递公司"
                });
                return false;
            }
            if(that.expNumberSel == ''){
            	this.$notify.error({
                    title: '异常',
                    offset: 100,
                    message: "请输入快递单号"
                });
                return false;
            }
        	let param = {};
        	param.orderId = that.excSendId; 
        	param.expressCompany = that.cityListChooseSel; 
        	param.expressKey = that.cityListChooseSelKey; 
        	param.expressCode = that.expNumberSel; 
            expressSellerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.excSendVisible = false;
        },
    	//选中快递-置换方的藏品发给被置换方
    	cityListChooseBuyFun(value){
    		console.log(value);
	          let obj = {};
	          obj = this.cityList.find((item)=>{
	              return item.no === value;
	          });
	          this.cityListChooseBuy = obj.com;
    	},
    	//发货-置换方的藏品发给被置换方
        buySendVisibleFun(row,index){
           if(row.id && row.id>0){
                this.buySendId = row.id; //确认ID
                this.buySendVisible = true; //显示兑换弹出框
            }
        },
        // 发货-置换方的藏品发给被置换方
        buySendVisibleFunOk(){
            let that = this;
            if(that.cityListChooseBuy == ''){
            	this.$notify.error({
                    title: '异常',
                    offset: 100,
                    message: "请选择快递公司"
                });
                return false;
            }
            if(that.expNumberBuy == ''){
            	this.$notify.error({
                    title: '异常',
                    offset: 100,
                    message: "请输入快递单号"
                });
                return false;
            }
        	let param = {};
        	param.orderId = that.buySendId; 
        	param.expressCompany = that.cityListChooseBuy; 
        	param.expressKey = that.cityListChooseBuyKey; 
        	param.expressCode = that.expNumberBuy; 
            expressBuyerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.buySendVisible = false;
        },
        //获取快递公司列表
    	getExpList(){
    		let that = this;
    		getExpressList().then(res =>{
    			if(res.resultcode == 200){
    				that.cityList = res.result;
    			}else{
    				this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: res.msg
                    });
    			}
    		})
    	},
    	//保证金-置换方
        buyReturnVisibleFun(row,index){
           if(row.id && row.id>0){
                this.excMarId = row.id; //确认ID
                this.buyMarVisible = true; //显示兑换弹出框
            }
        },
        // 保证金-置换方-退回
        buyReturnVisibleFunOk(){
           let that = this;
        	let param = {};
        	param.orderId = that.excMarId; 
        	param.result = 6; 
            refundBondBuyerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.buyMarVisible = false;
        },
        // 保证金-置换方-没收
        buyReturnVisibleFunNo(){
           let that = this;
        	let param = {};
        	param.orderId = that.excMarId; 
        	param.result = 7; 
            refundBondBuyerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.buyMarVisible = false;
        },
        //保证金-被置换方
        excReturnVisibleFun(row,index){
           if(row.id && row.id>0){
                this.excMarId = row.id; //确认ID
                this.excMarVisible = true; //显示兑换弹出框
            }
        },
        // 保证金-被置换方-退回
        excReturnVisibleFunOk(){
           let that = this;
        	let param = {};
        	param.orderId = that.excMarId; 
        	param.result = 8; 
            refundBondSellerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.excMarVisible = false;
        },
        // 保证金-被置换方-没收
        excReturnVisibleFunNo(){
           let that = this;
        	let param = {};
        	param.orderId = that.excMarId; 
        	param.result = 9; 
            refundBondSellerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.excMarVisible = false;
        },
    	//收货-被置换方
        excTakeVisibleFun(row,index){
           if(row.id && row.id>0){
                this.excTakeId = row.id; //确认ID
                this.excTakeVisible = true; //显示兑换弹出框
            }
        },
        // 收货-被置换方-同意
        excTakeVisibleFunOk(){
           let that = this;
        	let param = {};
        	param.orderId = that.excTakeId; 
            receiveSellerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.excTakeVisible = false;
        },
    	//收货-置换方
        buyTakeVisibleFun(row,index){
           if(row.id && row.id>0){
                this.buyTakeId = row.id; //确认ID
                this.buyTakeVisible = true; //显示兑换弹出框
            }
        },
        // 收货-置换方-同意
        buyTakeVisibleFunOk(){
           let that = this;
        	let param = {};
        	param.orderId = that.buyTakeId; 
            receiveBuyerExc(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.buyTakeVisible = false;
        },
    	//确认卖家是否同意
        handleDelete(row,index){
           if(row.id && row.id>0){
                this.delId = row.id; //确认ID
                this.delVisible = true; //显示兑换弹出框
            }
        },
        // 确认卖家是否同意-同意
        deleteRow(){
           let that = this;
        	let param = {};
        	param.orderId = that.delId; 
            param.result = 2; 
            param.reason = this.refuseReason;
            excConfirm(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
            this.delVisible = false;
        },
        // 确认卖家是否同意-不同意
        deleteRow2(row){
           let that = this;
        	let param = {};
        	param.orderId =that.delId; 
            param.result = 1; 
            param.reason = this.refuseReason;
            excConfirm(param).then((response)=> {
                if(response.code==200){
                    this.$notify({
                        title: '成功',
                        offset: 100,
                        type: 'success',
                        message: response.msg
                    });
                    that.getDate();
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })  
            this.delVisible = false;
        },
    	//发起置换方状态
    	buyStatu: function (row, column) {
    		let status;
    		switch(row.buyer_state){
    			case 0:
    			status = "待支付保证金";
    			break;
    			case 1:
    			status = "已支付保证金";
    			break;
    			case 2:
    			status = "已发货";
    			break;
    			case 3:
    			status = "平台已收货";
    			break;
    			case 4:
    			status = "平台已发货";
    			break;
    			case 5:
    			status = "已收对方藏品";
    			break;
    			case 6:
    			status = "保证金已退回";
    			break;
    			case 7:
    			status = "保证金没收";
    			break;
    			case 8:
    			status = "申请撤销";
    			break;
    			case 9:
    			status = "已关闭";
    			break;
    			default:
    			status = "异常";
    			break;
    		}
	        return status;
	    },
	    //被置换方状态
    	SelStatu: function (row, column) {
    		let status;
    		switch(row.seller_state){
    			case 0:
    			status = "待确认交易";
    			break;
    			case 1:
    			status = "不同意置换";
    			break;
    			case 2:
    			status = "同意置换待支付保证金";
    			break;
    			case 3:
    			status = "已支付保证金";
    			break;
    			case 4:
    			status = "已发货";
    			break;
    			case 5:
    			status = "平台已收货";
    			break;
    			case 6:
    			status = "平台已发货";
    			break;
    			case 7:
    			status = "已收对方藏品";
    			break;
    			case 8:
    			status = "保证金已退回";
    			break;
    			case 9:
    			status = "保证金没收";
    			break;
    			case 10:
    			status = "申请撤销";
    			break;
    			case 11:
    			status = "已关闭";
    			break;
    			default:
    			status = "异常";
    			break;
    		}
	        return status;
	    },
        //获取表格数据
        getDate(){
        	let that = this;
        	let param = {};
        	param.orderCode = that.orderCode; 
        	param.nickName = that.nickName; 
        	param.mobile = that.mobile; 
        	param.pageIndex = that.pageIndex; 
        	param.pageSize = that.pageSize; 
        	param.type = that.activeName;
            excListGet(param).then((response)=> {
                let _this = that;
                if(response.code==200){
                    var data = response.data;//当前返回的数据
                    that.totalElements = data.total; //总条数
                    that.totalPages = Math.ceil(data.total/that.pageSize);//总页数
                    that.tableData = data.list;//列表数据
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
        },
        //查询
        onSelect(){
            this.pageIndex =1;
            this.getDate();
        },
        //分页
        handleCurrentChange(val){
            this.pageIndex =val;
            this.getDate();
        },
        //切换订单类型
        handleClick(tab, event) {
            this.pageIndex = 1,//显示第一页
            this.paginationShow = false   //分页器消失
            this.$nextTick(function () {
                //分页器重新加载 解决element 分页器的无法触发current-change事件 只限在tabs页 
                this.paginationShow = true  
            })
	        this.activeName = tab.name;
	        this.getDate();
	      }
    }
}
</script>
<style lang="stylus" scoped>
    .edit{
        color #ff9800;
    }
    .del{
        color #e51c23;
    }
    .download{
        color #67C23A;
    }
</style>


<style>
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 210px;
    color: #99a9bf;
    text-align: right !important;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0 !important;
    margin-bottom: 0;
    width: 50%;
    box-sizing: border-box;
  }
</style>